package com.example.a313ldy.yuejian_17.Fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.a313ldy.yuejian_17.Adapter.ActivitiesAdapter;
import com.example.a313ldy.yuejian_17.Bean.Activities;
import com.example.a313ldy.yuejian_17.Listener.ActivitiesListener;
import com.example.a313ldy.yuejian_17.Model.ActivitiesModel;
import com.example.a313ldy.yuejian_17.R;

import java.util.List;

/**
 * Created by LDY on 2017/10/9.
 */

public class IndexFragment extends Fragment implements ActivitiesListener<Activities> {

        View v;
        RecyclerView recyclerView_Activitieslist;
        @Override
        public View onCreateView(LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState)
        {
            v = inflater.inflate(R.layout.fragment_main, null) ;
            recyclerView_Activitieslist = (RecyclerView)v.findViewById(R.id.id_fragment_main);
            recyclerView_Activitieslist.setLayoutManager(new LinearLayoutManager(getActivity()));
            ActivitiesModel ActivitiesModel = new ActivitiesModel();
            ActivitiesModel.activitiesData(this);
            return v ;
        }


        @Override
        public void onResponse(Activities Activities) {
            List<Activities.ActivitydataEntity> ActivitydataEntity = Activities.getActivitydata();
            System.out.println("+++++"+ActivitydataEntity);
            ActivitiesAdapter adapter = new ActivitiesAdapter(getActivity(),ActivitydataEntity);
            recyclerView_Activitieslist.setAdapter(adapter);
        }

        @Override
        public void onFail(String msg) {
            System.out.println("+++++"+"失败率");
        }
    }
